package com.entmanage.base.oa.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.entmanage.common.annotation.Log;
import com.entmanage.common.core.controller.BaseController;
import com.entmanage.common.core.domain.AjaxResult;
import com.entmanage.common.enums.BusinessType;
import com.entmanage.base.oa.domain.OaReimbursementDetail;
import com.entmanage.base.oa.service.IOaReimbursementDetailService;
import com.entmanage.common.utils.poi.ExcelUtil;
import com.entmanage.common.core.page.TableDataInfo;

/**
 * OA报销申请-费用明细Controller
 *
 * @author lsq
 * @date 2025-09-25
 */
@Api(tags = {"oa-OaReimbursementDetail模块"}, description = "OA报销申请-费用明细")
@RestController
@RequestMapping("/oa/reimbursement_detail")
public class OaReimbursementDetailController extends BaseController
{
    @Autowired
    private IOaReimbursementDetailService oaReimbursementDetailService;

    /**
     * 查询OA报销申请-费用明细列表
     */
    @PreAuthorize("@ss.hasPermi('oa:reimbursement_detail:list')")
    @GetMapping("/list")
    public TableDataInfo list(OaReimbursementDetail oaReimbursementDetail)
    {
        startPage();
        List<OaReimbursementDetail> list = oaReimbursementDetailService.selectOaReimbursementDetailList(oaReimbursementDetail);
        return getDataTable(list);
    }

    /**
     * 导出OA报销申请-费用明细列表
     */
    @PreAuthorize("@ss.hasPermi('oa:reimbursement_detail:export')")
    @Log(title = "OA报销申请-费用明细", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, OaReimbursementDetail oaReimbursementDetail)
    {
        List<OaReimbursementDetail> list = oaReimbursementDetailService.selectOaReimbursementDetailList(oaReimbursementDetail);
        ExcelUtil<OaReimbursementDetail> util = new ExcelUtil<OaReimbursementDetail>(OaReimbursementDetail.class);
        util.exportExcel(response, list, "OA报销申请-费用明细数据");
    }

    /**
     * 获取OA报销申请-费用明细详细信息
     */
    @PreAuthorize("@ss.hasPermi('oa:reimbursement_detail:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(oaReimbursementDetailService.selectOaReimbursementDetailById(id));
    }

    /**
     * 新增OA报销申请-费用明细
     */
    @PreAuthorize("@ss.hasPermi('oa:reimbursement_detail:add')")
    @Log(title = "OA报销申请-费用明细", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OaReimbursementDetail oaReimbursementDetail)
    {
        return toAjax(oaReimbursementDetailService.insertOaReimbursementDetail(oaReimbursementDetail));
    }

    /**
     * 修改OA报销申请-费用明细
     */
    @PreAuthorize("@ss.hasPermi('oa:reimbursement_detail:edit')")
    @Log(title = "OA报销申请-费用明细", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody OaReimbursementDetail oaReimbursementDetail)
    {
        return toAjax(oaReimbursementDetailService.updateOaReimbursementDetail(oaReimbursementDetail));
    }

    /**
     * 删除OA报销申请-费用明细
     */
    @PreAuthorize("@ss.hasPermi('oa:reimbursement_detail:remove')")
    @Log(title = "OA报销申请-费用明细", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(oaReimbursementDetailService.deleteOaReimbursementDetailByIds(ids));
    }
}
